home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PsL Monthly 1993 December
/
PSL Monthly Shareware CD-ROM (December 1993).iso
/
prgmming
/
dos
/
c
/
graph_pl.exe
/
DEMO.C
< prev
next >
Wrap
C/C++ Source or Header
|
1992-02-05
|
8KB
|
207 lines
/*
******************************************************************
** *
** THAT MATERIAL CONTAINED HEREIN WHICH WAS SUPPLIED BY PAUL *
** LAPSANSKY IS PROPRIETARY TO PAUL LAPSANSKY AND IS NOT TO *
** BE REPRODUCED, USED OR DISCLOSED EXCEPT IN ACCORDANCE WITH *
** PROGRAM LICENSE OR UPPON WRITTEN AUTHORIZATION OF: *
** *
** PAUL LAPSANSKY *
** 1905 BEECH ST. APT. 317 *
** VALPARAISO, INDIANA 46383 *
** *
** GENIE: *
** P.LAPSANSKY *
** *
******************************************************************
PROGRAM-ID. DEMO.C
AUTHOR. PAUL LAPSANSKY
DATE-WRITTEN. FEBRUARY 5, 1992
******************************************************************
** *
** TITLE: DEMO PROGRAM FOR GRAPHS LIBRARY *
** *
** PROGRAM DESCRIPTION: *
** *
** This program is a working demo of the graph functions *
** bargraph, bargraph3d, and piechart. This program *
** requires Turbo C version 1.5 or higher, Turbo C++ or *
** Borland C++. This program must be linked with the *
** graphs library GRAPH_C.LIB. The BGI and FONT files *
** must reside in the same directory as the compiler or *
** linked with the program. *
** *
******************************************************************
******************************************************************
** *
** MAINTENANCE HISTORY: *
** *
** DATE REVISED BY VER # DESCRIPTION *
** *
** 02/05/92 PAUL LAPSANSKY 1.00 ORIGINAL CODE. *
** *
******************************************************************
******************************************************************
** *
** COMPILER-OPTIONS: *
** *
** MEMORY-MODEL: COMPACT *
** *
** FLOATING-POINT: ON *
** *
******************************************************************
*/
#include <graphics.h>
#include <stdlib.h>
#include <string.h>
#define AUTO 0
main()
{
int driver; /* display driver */
int num_pts; /* number of data points */
int font; /* text font */
int pattern; /* graph fill pattern */
int color; /* graph fill color */
int size; /* text size */
int gr_return; /* error code returned by graph functions */
float max; /* largest data value */
float data[12]={10,20,3,4.5,15,7,1,15,8,5.9,11,3}; /* data values */
char x_label[20]; /* x-axis label */
char y_label[20]; /* y-axis label */
char title[20]; /* graph title */
char footnote[40]; /* pie chart footnote */
char values[12][10]={"JAN","FEB","MAR","APR","MAY","JUN",
"JUL","AUG","SEP","OCT","NOV","DEC"};
/* display bargraph */
driver=DETECT; /* detect display adapter */
num_pts=12;
font=TRIPLEX_FONT;
pattern=SOLID_FILL;
color=GREEN;
size=2; /* reduce x-axis values */
max=AUTO; /* determine largest data value and auto scale graph */
strcpy(x_label,"X-AXIS");
strcpy(y_label,"Y-AXIS");
strcpy(title,"BARGRAPH DEMO");
gr_return=bargraph(driver,num_pts,data,max,font,pattern,
color,x_label,y_label,title,values,size);
gr_error(gr_return);
getch();
/* display 3D bargraph */
color=BROWN;
strcpy(title,"3D BARGRAPH DEMO");
gr_return=bargraph3d(driver,num_pts,data,max,font,pattern,
color,x_label,y_label,title,values,size);
gr_error(gr_return);
getch();
/* display piechart */
strcpy(title,"PIE-CHART DEMO");
strcpy(footnote,"Footnote goes here!");
gr_return=piechart(driver,num_pts,data,pattern,font,
title,footnote,values,size);
gr_error(gr_return);
getch();
restorecrtmode(); /* restore previous display and memory */
exit(0);
}
gr_error(gr_return)
int gr_return;
{
switch(gr_return) {
case grOk: /* successful */
break;
case grNoInitGraph:
printf("\n%s\n","No driver installed");
exit(0);
break;
case grNotDetected:
printf("\n%s\n","No graphics hardware in system");
exit(0);
break;
case grFileNotFound:
printf("\n%s\n","Driver file not found");
exit(0);
break;
case grInvalidDriver:
printf("\n%s\n","Invalid driver file");
exit(0);
break;
case grNoLoadMem:
printf("\n%s\n","Not enough memory");
exit(0);
break;
case grNoScanMem:
printf("\n%s\n","Insufficient memory for scan fill");
exit(0);
break;
case grNoFloodMem:
printf("\n%s\n","Insufficient memory for flood fill");
exit(0);
break;
case grFontNotFound:
printf("\n%s\n","Font file not found");
exit(0);
break;
case grNoFontMem:
printf("\n%s\n","Insufficient memory for font");
exit(0);
break;
case grInvalidMode:
printf("\n%s\n","Invalid mode");
exit(0);
break;
case grError:
printf("\n%s\n","General graphics error");
exit(0);
break;
case grIOerror:
printf("\n%s\n","I/O error");
exit(0);
break;
case grInvalidFont:
printf("\n%s\n","Invalid font file");
exit(0);
break;
case grInvalidFontNum:
printf("\n%s\n","Invalid font number");
exit(0);
case -18: /* not available on all versions of Turbo C */
printf("%s\n","Incorrect driver version");
exit(0);
break;
case -25:
printf("\n%s\n","Too many data points");
exit(0);
default:
printf("\n%s\n","Undetectable error");
printf("%d",gr_return);
exit(0);
}
}